import java.util.Arrays;

/**
 * @author ZhiWen Ren
 * @version 1.0
 * @description: LeetCode-309-最长递增子序列
 * @date 2025/8/14 15:03
 */
public class Solution300 {
    public int lengthOfLIS(int[] nums) {
        int maxLen = 1;
        // dp[i]代表以第i结束的子序列的最长递增长度
        int[] dp = new int[nums.length];

        for (int i = 0; i < nums.length; i++) {
            dp[i] = 1;
            for (int j = i - 1; j >= 0; j--) {
                if (nums[i] > nums[j]) {
                    dp[i] = Math.max(dp[i], dp[j] + 1);
                }
            }
            maxLen = Math.max(maxLen, dp[i]);
        }

        return maxLen;
    }
}
